package pers.lx.crm.controller.info;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import pers.lx.crm.base.common.pigeon.Result;
import pers.lx.crm.entiy.info.InfoListDO;
import pers.lx.crm.entiy.info.TemplateDO;
import pers.lx.crm.service.info.TemplateService;

/**
 * Created by lx on 2017/3/6.
 */
@Controller
@RequestMapping(value = "template")
public class TemplateController {

    @Autowired
    private TemplateService templateService ;

    @RequestMapping(value = "/list")
    public @ResponseBody
    Result getTemplates(TemplateDO templateDO){
        return templateService.getTemplates(templateDO);
    }

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public @ResponseBody
    Result addTemplate(@RequestBody TemplateDO templateDO){
        return templateService.addTemplate(templateDO) ;
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public @ResponseBody
    Result updateTemplate(@RequestBody TemplateDO templateDO){
        return templateService.updateTemplate(templateDO);
    }

    @RequestMapping(value = "/remove",method = RequestMethod.POST)
    public @ResponseBody
    Result removeTemplate(@RequestBody InfoListDO infoListDO){
        return templateService.removeTemplate(infoListDO.getTemplateDOs()) ;
    }

    @RequestMapping(value = "/listTagBlock")
    public @ResponseBody
    Result getTagBlockLost(@RequestBody TemplateDO templateDO){
        return templateService.getTagsBlock(templateDO) ;
    }

}
